package D01_03;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class Demo5 {
    public static void main(String[] args) throws IOException {
//        run1();
        run2();
    }
    public static void run1() throws IOException {
        byte[] bytes = FileUtils.readFileToByteArray(new File("src/Y2020/D01_03/time.png"));
        int i = 1,a = 409600;
        int start = 0;
        while (true){
            if (start+a>bytes.length){
                FileUtils.writeByteArrayToFile(new File("src/Y2020/D01_03/拆分图片/"+i+".png"),bytes,start,bytes.length-start);
                return;
            }
            FileUtils.writeByteArrayToFile(new File("src/Y2020/D01_03/拆分图片/"+i+".png"),bytes,start,a);
            start+=a;
            i++;
        }
    }
    public static void run2() throws IOException {
        for (int i = 1; i <=5 ; i++) {
            byte[] bytes = FileUtils.readFileToByteArray(new File("src/Y2020/D01_03/拆分图片/" + i + ".png"));
            FileUtils.writeByteArrayToFile(new File("src/Y2020/D01_03/合成图片/1.png"),bytes,true);
        }
    }
}
